package com.ysj.demo.accompanynetwork.weight;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;

import com.ysj.demo.accompanynetwork.R;
import com.ysj.demo.accompanynetwork.util.StatusBarUtil;
import com.ysj.demo.accompanynetwork.adapter.PlayerTypeAdapter;
import com.ysj.demo.accompanynetwork.bean.PlayerTypeBean;
import com.ysj.demo.accompanynetwork.util.ToolUtil;

import java.util.List;

/**
 * Created by 80530 on 2018/8/13.
 */

public class PlayerTypePopWindow extends PopupWindow {
    private ListView lv;
    private View mMenuView;

    public PlayerTypePopWindow(final Activity context, List<PlayerTypeBean> list, AdapterView.OnItemClickListener itemsOnClick) {
        super(context);
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mMenuView = inflater.inflate(R.layout.pop_city_layout, null);
        lv = mMenuView.findViewById(R.id.lv);
        PlayerTypeAdapter adapter = new PlayerTypeAdapter(context, list);
        lv.setAdapter(adapter);
        adapter.notifyDataSetChanged();
        lv.setOnItemClickListener(itemsOnClick);

        //设置SelectPicPopupWindow的View
        this.setContentView(mMenuView);
        //设置SelectPicPopupWindow弹出窗体的宽
        this.setWidth((int) (ToolUtil.getScreenWidth(context) * 0.5));
        //设置SelectPicPopupWindow弹出窗体的高
        this.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
        //设置SelectPicPopupWindow弹出窗体可点击
        this.setFocusable(true);
        //设置SelectPicPopupWindow弹出窗体动画效果
        this.setAnimationStyle(R.style.AnimBottom);
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(0xb0000000);
        //设置SelectPicPopupWindow弹出窗体的背景
        this.setBackgroundDrawable(dw);

    }
}
